// service,
export const fatherAndSonUpdates = (fatherService, fatherId, sonService, depend_keys, state_key, state_value, datas) => {
	 
	let params = [{
		"serviceName": fatherService,
		"condition": [{
			"colName": "id",
			"ruleType": "eq",
			"value": fatherId
		}],
		"data": []
	}];

	let child_data_list = [];
 

	for (let i in datas) {
		let item = datas[i];
		let confition=[];
		if(item.id){
			confition=[{
				"colName": "id",
				"ruleType": "eq",
				"value": item.id
			}]
		}else{
			sonService=sonService.replace("update","add")
		}
		 
		child_data_list.push({
			"serviceName": sonService,
			"condition": confition,
			"depend_keys":item.id?[]: [{
				"type": "column",
				"add_col": depend_keys,
				"depend_key": depend_keys
			}],
			"data": [
				item
			]
		})
	}
	let d={
		"child_data_list": child_data_list
	};
	d[state_key]=state_value
	 
	params[0].data .push(d);
	return params;
}
 
export const fatherAndSonAdds =  (fatherService, sonService, depend_key, state_key, state_value, datas) =>{

	let params= [{
		"serviceName": fatherService,
		"condition": [],
		"data": [{
			// state_key: state_value,
			"child_data_list": [{
				"serviceName": sonService,
				"condition": [],
				"depend_keys": [{
					"type": "column",
					"add_col": depend_key,
					"depend_key": depend_key
				}],
				"data": datas
			}]
		}]
	}];
	params[0].data[0][state_key]=state_value;
	return params;
}
 
